﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LaoLuo
{
    /// <summary>
    /// Exception thrown to indicate that an inappropriate type argument was used for a type parameter to a generic type or method
    /// </summary>
    public class TypeArgumentException : ArgumentException
    {
        private const string TypeFormat = "type must be {0}";

        /// <summary>
        /// Constructs a new instance of <see cref="TypeArgumentException"/>
        /// </summary>
        /// <param name="message"></param>
        /// <param name="paramName"></param>
        /// <param name="innerException"></param>
        public TypeArgumentException(string message, string paramName = "T", Exception innerException = null)
            : base(message, paramName, innerException)
        {

        }

        /// <summary>
        /// Constructs a new instance of <see cref="TypeArgumentException"/>
        /// </summary>
        /// <param name="typeNeeded"></param>
        /// <param name="paramName"></param>
        /// <param name="innerException"></param>
        public TypeArgumentException(Type typeNeeded, string paramName = "T", Exception innerException = null)
            : base(string.Format(TypeFormat, typeNeeded), paramName, innerException)
        {

        }
    }
}
